package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.entity.WarningRule;
import com.ruoyi.system.mapper.WarningRuleMapper;
import com.ruoyi.system.service.WarningRuleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author ruochen
* @description 针对表【warning_rule(预警规则表)】的数据库操作Service实现
* @createDate 2023-12-01 09:33:50
*/
@Service
public class WarningRuleServiceImpl extends ServiceImpl<WarningRuleMapper, WarningRule>
    implements WarningRuleService{

    @Override
    public List<WarningRule> getWarningRuleList(WarningRule warningRule) {

        LambdaQueryWrapper<WarningRule> warningRuleLambdaQueryWrapper = new LambdaQueryWrapper<>();
        //创建时间倒序排列
        warningRuleLambdaQueryWrapper.orderByDesc(WarningRule::getCreateTime);
        if (warningRule.getState()!=null){
            warningRuleLambdaQueryWrapper.eq(WarningRule::getState,warningRule.getState());
        }


        return this.list(warningRuleLambdaQueryWrapper);
    }

    @Override
    public WarningRule getWarningRuleById(Long id) {
        WarningRule warningRule = this.getById(id);
        return warningRule;
    }
}




